package com.hxh.basic.project.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxh.basic.project.entity.ClubCommentInfo;
import com.hxh.basic.project.form.comment.ListCommentForm;
import com.hxh.basic.project.service.IClubCommentInfoService;
import com.hxh.basic.project.service.IClubForumInfoService;
import com.hxh.basic.project.utils.ResultVoUtil;
import com.hxh.basic.project.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zouyujie
 * @since 2022-11-09
 */
@CrossOrigin
@RestController
@RequestMapping("/club-comment-info")
public class ClubCommentInfoController {

    @Resource
    private IClubCommentInfoService clubCommentInfoService;

    @PostMapping("/add")
    public ResultVo add(@RequestBody ClubCommentInfo clubCommentInfo){
        Boolean result = clubCommentInfoService.save(clubCommentInfo);
        return ResultVoUtil.success();
    }

    @PostMapping("/list")
    public ResultVo list(@RequestBody ListCommentForm listCommentForm){
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.eq("type",1);
        queryWrapper.eq("objectId",listCommentForm.getForumId());
        List<ClubCommentInfo> clubCommentInfoList = clubCommentInfoService.list(queryWrapper);
        return ResultVoUtil.success(clubCommentInfoList);
    }

}
